home *** CD-ROM | disk | FTP | other *** search
/ PC Open 96 / PC Open 96 CD3.bin / fscommand / index.swf / scripts / %3Cdefault package%3E / SUB_PARSER.as < prev    next >
Encoding:
Text File  |  2004-01-08  |  1.7 KB  |  65 lines

  1. _global.subParserCLASS = function()
  2. {
  3. };
  4. _global.subParserCLASS.prototype.setOnData = function(target, method)
  5. {
  6.    this.onDataTarget = target;
  7.    this.onDataMethod = method;
  8. };
  9. _global.subParserCLASS.prototype.getOnData = function(target, name)
  10. {
  11.    return this.onDataTarget[this.onDataMethod];
  12. };
  13. _global.subParserCLASS.prototype.unload = function()
  14. {
  15.    clearInterval(this.subTypeParserInterval);
  16.    delete this.sSubtitle;
  17.    this.setOnData(null);
  18.    this.subTypeParser.unload();
  19.    delete this.subTypeParser;
  20. };
  21. _global.subParserCLASS.prototype.load = function(file, subObj)
  22. {
  23.    this.unload();
  24.    this.file = file;
  25.    this.subObj = subObj;
  26.    this.xDoc.onData = null;
  27.    this.xDoc = new XML();
  28.    this.xDoc.controller = this;
  29.    this.xDoc.onData = function(str)
  30.    {
  31.       this.controller.sSubtitle = str;
  32.       this.controller.onData();
  33.    };
  34.    this.xDoc.load(file);
  35. };
  36. _global.subParserCLASS.prototype.onData = function()
  37. {
  38.    var type;
  39.    type = this.file.split(".").pop();
  40.    if(type == "srt")
  41.    {
  42.       this.subTypeParser = new _global.SRT_CLASS();
  43.    }
  44.    else
  45.    {
  46.       trace("Le type du fichier n\'a pu ├¬tre determin├⌐");
  47.       this.onDataTarget[this.onDataMethod]();
  48.    }
  49.    this.subTypeParser.setOnData(this,"onParse");
  50.    this.subTypeParser.parse(this.sSubtitle,this.subObj);
  51. };
  52. _global.subParserCLASS.prototype.onParse = function()
  53. {
  54.    this.subTypeParser.unload();
  55.    this.onDataTarget[this.onDataMethod](this.subObj);
  56. };
  57. _global.subParserCLASS.prototype.getBytesLoaded = function()
  58. {
  59.    return !this.subTypeParser ? 0 : this.subTypeParser.index;
  60. };
  61. _global.subParserCLASS.prototype.getBytesTotal = function()
  62. {
  63.    return this.sSubtitle != null ? this.sSubtitle.length : 0;
  64. };
  65.